package com.manager.mail;

import com.manager.commons.config.ConfigFactory;

public class MailUtil {

	/**
	 * @param args
	 */
	private static String serverHost=ConfigFactory.getInstance().getConfig().getString("framework.sync.email","serverHost");
	private static String serverPort=ConfigFactory.getInstance().getConfig().getString("framework.sync.email","serverPort");
	private static String userName=ConfigFactory.getInstance().getConfig().getString("framework.sync.email","userName");
	private static String password=ConfigFactory.getInstance().getConfig().getString("framework.sync.email","password");
	private static String fromAddress=ConfigFactory.getInstance().getConfig().getString("framework.sync.email","fromAddress");
	
	public void sendEmail(String title, String content, String toEmail) {
		MailSenderInfo mailInfo = new MailSenderInfo();
		SimpleMailSender sm = new SimpleMailSender();
		mailInfo.setMailServerHost(serverHost);
		mailInfo.setMailServerPort(serverPort);
		mailInfo.setValidate(true);
		mailInfo.setUserName(userName);
		mailInfo.setPassword(password);
		mailInfo.setFromAddress(fromAddress);
		mailInfo.setToAddress(toEmail);
		mailInfo.setSubject(title);
		mailInfo.setContent(content);
		sm.sendTextMail(mailInfo);
	}

}
